package cn.alpha.intell.rbtlib.wifi.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import cn.alpha.intell.rbtlib.R;


/**
 * Created by huangzhiqin on 2016/10/9.
 */
public class AddWiFiItemAdapter extends BaseAdapter{
    private Context context;
    private LayoutInflater layoutInflater;
    private List<String> list;

    public AddWiFiItemAdapter( Context context) {
        this.layoutInflater = LayoutInflater.from(context);
        this.context = context;
    }
    public void setData(List<String> list){
        this.list=list;
    }

    @Override
    public int getCount() {
        return list.size()>0?list.size():0;
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AddWiFiHolder holder = null;
        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.add_wifi_item_listview, parent, false);
            holder=new AddWiFiHolder();
            holder.type=(TextView)convertView.findViewById(R.id.add_wifi_item_tv);
            holder.down=(ImageView)convertView.findViewById(R.id.add_wifi_item_down);
            convertView.setTag(holder);
        }
        else {
            holder= (AddWiFiHolder) convertView.getTag();
        }
        holder.type.setText(list.get(position));
        if (0==position){
            holder.down.setVisibility(View.VISIBLE);
        }else {
            holder.down.setVisibility(View.GONE);
        }

        return convertView;
    }
    class AddWiFiHolder{
        TextView type;
        ImageView down;
    }

}
